package com.ruoyi.bussiness.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.AdCompany;
import com.ruoyi.bussiness.service.IAdCompanyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广告公司Controller
 * 
 * @author ruoyi
 * @date 2023-11-12
 */
@Controller
@RequestMapping("/bussiness/aDcompany")
public class AdCompanyController extends BaseController
{
    private String prefix = "bussiness/aDcompany";

    @Autowired
    private IAdCompanyService adCompanyService;

    @RequiresPermissions("bussiness:aDcompany:view")
    @GetMapping()
    public String aDcompany()
    {
        return prefix + "/aDcompany";
    }

    /**
     * 查询广告公司列表
     */
    @RequiresPermissions("bussiness:aDcompany:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AdCompany adCompany)
    {
        startPage();
        List<AdCompany> list = adCompanyService.selectAdCompanyList(adCompany);
        return getDataTable(list);
    }

    /**
     * 导出广告公司列表
     */
    @RequiresPermissions("bussiness:aDcompany:export")
    @Log(title = "广告公司", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AdCompany adCompany)
    {
        List<AdCompany> list = adCompanyService.selectAdCompanyList(adCompany);
        ExcelUtil<AdCompany> util = new ExcelUtil<AdCompany>(AdCompany.class);
        return util.exportExcel(list, "广告公司数据");
    }

    /**
     * 新增广告公司
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存广告公司
     */
    @RequiresPermissions("bussiness:aDcompany:add")
    @Log(title = "广告公司", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AdCompany adCompany)
    {
        return toAjax(adCompanyService.insertAdCompany(adCompany));
    }

    /**
     * 修改广告公司
     */
    @RequiresPermissions("bussiness:aDcompany:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AdCompany adCompany = adCompanyService.selectAdCompanyById(id);
        mmap.put("adCompany", adCompany);
        return prefix + "/edit";
    }

    /**
     * 修改保存广告公司
     */
    @RequiresPermissions("bussiness:aDcompany:edit")
    @Log(title = "广告公司", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AdCompany adCompany)
    {
        return toAjax(adCompanyService.updateAdCompany(adCompany));
    }

    /**
     * 删除广告公司
     */
    @RequiresPermissions("bussiness:aDcompany:remove")
    @Log(title = "广告公司", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(adCompanyService.deleteAdCompanyByIds(ids));
    }
}
